ht <- function (TS, n=5) {
  c(head(TS, n=n), tail(TS, n=n))
}

htXTSList <- function (pattern, n=5) {
  result <- list()
  for (i in 1:length(pattern)) {
    result[[names(pattern)[i]]] <- ht(pattern[[i]], n=n)
  }
  return (result)
}

prevBusinessDay <- function(date) {
  if(format(date - 1, '%w') %in% c(0, 6)) {
    Recall(date - 1)
  } else {
    return (date - 1)
  }
}